<?php
/**
 * Created by PhpStorm.
 * User: shorton
 * Date: 2019/3/29
 * Time: 4:24 PM
 */



class Import
{

    /**
     * @param string $path
     * @return array
     * @throws PHPExcel_Exception
     * @throws PHPExcel_Reader_Exception
     */
    public static function importExcelToArray($path)
    {
        $type = 'Excel2007';//设置为Excel5代表支持2003或以下版本，Excel2007代表2007版
        $xlsReader = PHPExcel_IOFactory::createReader($type);
        $xlsReader->setReadDataOnly(true);
        $xlsReader->setLoadSheetsOnly(true);
        $Sheets = $xlsReader->load($path);
        //开始读取上传到服务器中的Excel文件，返回一个二维数组
        return $Sheets->getSheet(0)->toArray();
    }
}